package com.flash.dailyreport.service.handler.news;

import com.alibaba.fastjson.JSONObject;
import com.flash.dailyreport.entity.NewsEntity;
import com.flash.dailyreport.util.HttpClientUtils;
import com.flash.dailyreport.util.HttpTextResponse;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author sunyiming
 * @date 2018/8/17
 */
public class SinaNewsHandler implements NewsHandler {

    HttpClientUtils client = HttpClientUtils.getInstance();

    @Override
    public Map<String, List<NewsEntity>> getMainNews() {

        Map<String, List<NewsEntity>> map = new HashMap<>();
        HttpTextResponse httpTextResponse = client.doHttpGet("https://news.sina.com.cn/", null);
        String html = httpTextResponse.getResponseBody();
        Document document = Jsoup.parse(html);
        Element mainNewsDiv = document.getElementById("syncad_1");

        return map;

    }
}
